import pytest
from playwright.sync_api import sync_playwright

"""
测试环境的隔离
"""

@pytest.fixture
def page():
    with sync_playwright() as p:
        print("pre")
        browser = p.chromium.launch(headless=False, slow_mo=200)
        context = browser.new_context()
        page = context.new_page()
        yield page
        print("post")
        context.close()
        browser.close()


# 默认会读取pytest.ini配置文件中的 base_url
def test_base_url_1(base_url):
    print("base_url: ", base_url)


# 可以通过命令行 --base-url 或者 pytest.ini 文件来配置
def test_base_url_2(page, base_url):
    print("base_url: ", base_url)
    page.goto(base_url + "/xxl-job-admin/toLogin")
    page.pause()
